#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> constructTransformedArray(vector<int>& nums) {
    int n = nums.size();
    vector<int> res(n);
    for (int i = 0; i < n; i++)
        if (nums[i] != 0)
            res[i] = nums[((i + nums[i]) % n + n) % n];
    return res;
}

int missingNumber(vector<int>& nums) {
    sort(nums.begin(), nums.end());
    int l = 0, r = nums.size();

    auto check = [&](int mid)->bool {
        return nums[mid] != mid;
    };

    while (l < r)
    {
        int mid = l + r >> 1;
        if (check(mid))  r = mid;
        else l = mid + 1;
    }
    return l;
}